package com.guxingke.gblog.dao.impl;

import java.util.List;

import com.guxingke.gblog.dao.MsgDao;
import com.guxingke.gblog.dmo.Msg;
import com.guxingke.gblog.dto.MsgDto;

public class MsgDaoImpl extends BaseDao implements MsgDao {
	private MsgDao dao = null;

	@Override
	public List<MsgDto> getComments(int articleId) throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		List<MsgDto> result = dao.getComments(articleId);

		end();
		return result;
	}

	@Override
	public List<MsgDto> getLeaveMsgs() throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		List<MsgDto> result = dao.getLeaveMsgs();

		end();
		return result;
	}

	@Override
	public void save(Msg msg) throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		dao.save(msg);

		end();

	}

	@Override
	public void delete(int id) throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		dao.delete(id);

		end();
	}

	@Override
	public List<MsgDto> getRecentMsgs() throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		List<MsgDto> result = dao.getRecentMsgs();

		end();
		return result;
	}

	@Override
	public List<MsgDto> all() throws Exception {
		begin();
		dao = session.getMapper(MsgDao.class);

		List<MsgDto> result = dao.all();

		end();
		return result;
	}

}
